package javaStudy.算法;

import java.util.Scanner;

public class 牛牛切割机 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr=new int[n];
        int[] sum1=new int[n-1];  //分割前端的和
        int[] sum2=new int[n-1];  //分割后端的和
        for (int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        for(int i=0;i<n-1;i++){
            int a=0;
            for (int j=0;j<=i;j++){
                a+=arr[j];
            }
            sum1[i]=a;
        }
        for(int i=0;i<n-1;i++){
            int a=0;
            for (int j=i+1;j<n;j++){
                a+=arr[j];
            }
            sum2[i]=a;
        }
        int min=sum1[0]*sum2[0];
        for (int i=1;i<sum1.length;i++){
            if (sum1[i]*sum2[i]<min){
                min=sum1[i]*sum2[i];
            }
        }
        System.out.println(min);
    }
}
